{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-02-10T02:25:22.530192Z",
     "start_time": "2025-02-10T02:25:22.428321Z"
    }
   },
   "source": [
    "#列表转ndarray\n",
    "import numpy as np\n",
    "\n",
    "list1 = [1, 2, 3, 4]\n",
    "print(list1)\n",
    "print(type(list1))\n",
    "\n"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4]\n",
      "<class 'list'>\n"
     ]
    }
   ],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-02-10T02:25:41.856833Z",
     "start_time": "2025-02-10T02:25:41.852907Z"
    }
   },
   "cell_type": "code",
   "source": [
    "oneArray = np.array(list1)\n",
    "print(type(oneArray))  #类型是ndarray\n",
    "print(oneArray)"
   ],
   "id": "e054244cbbaf0b0",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'numpy.ndarray'>\n",
      "[1 2 3 4]\n"
     ]
    }
   ],
   "execution_count": 2
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
